<li>
  <% attr_id = AnnotationAttribute.find_by_name("category").id %>
  <% count = Annotation.find(:all, :conditions => {:attribute_id => attr_id,
      :value => cat.id}).size %>
  <%= link_to "#{cat.name} (#{count})", :controller => "shims", 
      :action => "with_annotation", :attribute_name => "category", 
      :value => cat.id %>  
  <% unless cat.children? %>
    <% cat_expanded = cookies["expanded_cat_#{cat.name}"] == "true" %>
    <%= link_to_function(cat_expanded ? "-" : "+", nil, :class => "active", 
        :style => "", :id => "expand_#{cat.name}", 
        :onclick => "categoryToggle(\"#{cat.name}\");")%>
    <div id="<%= cat.name -%>" style="<%= (cat_expanded ? "margin-left:5px;" : "display:none;margin-left:5px;") -%>">
      <ul>
        <%= render :partial => 'layouts/sub_category_div', 
            :collection => cat.children, :as => :cat %>
      </ul>
    </div>
  <% else %>
  <% end %>
</li>